package logic

import (
	"context"
	"shuqi-novel/model"

	"shuqi-novel/novelrpc/internal/svc"
	"shuqi-novel/novelrpc/novelrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UploadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogic {
	return &UploadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UploadLogic) Upload(in *novelrpc.UploadRequest) (*novelrpc.UploadResponse, error) {
	// todo: add your logic here and delete this line

	story := model.Story{
		Img:    in.Img,
		Title:  in.Title,
		About:  in.About,
		Status: in.Status,
	}
	model.DB.Debug().Updates(&story)
	return &novelrpc.UploadResponse{
		Id: int64(story.ID),
	}, nil
}
